const app = getApp();
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		card:[]
	},

  //生命周期函数--监听页面显示
  onShow: function () {
    app.loginState((state)=>{
			if(state){
				this.getCard();
			}
    },false)
  },
	//读取优惠券
	getCard: function () {
    app.api().Get('api/v1/ais/gmcard/index',(result) => {
			if(200 == result.code){
				this.setData({
					card:result.data,
				});
			}
    })
	},
	onCreate: function () {
		wx.navigateTo({
			url: 'create',
		})
	},
	onEdit: function (e) {
		var card = this.data.card;
		wx.navigateTo({
			url: 'create?id='+card[e.currentTarget.dataset.key].id,
		})
	},
})